package com.fwtai.config;

import java.io.Serializable;
import java.util.Arrays;

/**
 * 全局统一的配置变量及标识码-客户端和服务器端
 * @提示 code为200正常;msg的提示信息
 * @作者 田应平
 * @版本 v1.0
 * @创建时间 2017年1月11日 10:11:29
 * @QQ号码 444141300
 * @官网 http://www.fwtai.com
*/
public final class ConfigFile implements Serializable{

  private ConfigFile(){}

  public final static short workerIdWeb = 1;//数据中心节点标记,仅需改动此值即可。默认值6，限定 WorkerId 最大值为2^6-1，即默认最多支持64个节点。取值范围：当WorkerIdBitLength=8时2的8次方是256-1=255;相当于可以部署255个服务(器);2的9次方=512-1(个服务[器]);若是10，则是1023,即2的10次方-1个微服务(器)
  public final static short workerIdApi = 1;//api部署的服务id(数据中心节点标记),仅需改动此值即可,取值范围是最大值 2^WorkerIdBitLength-1,同上
  public final static short workerLength = 9;
  public final static short seqLength = 13;

  public final static String URL_LOGIN_PAGE = "/login.html";//登录页面

  public final static String URL_INDEX_PAGE = "/index.html";//首页页面

  private final static String v10 = "v1.0/";

  public final static String api_v10 = "/api/"+v10;

  public final static String URL_REGISTER = api_v10 + "user/register";//放行对外提供注册接口url
  public final static String URL_GET_CODE = api_v10 + "code/getCode";//获取验证码
  public final static String URL_USER_FORGET = api_v10 + "user/forget";//忘记密码

  public final static String URL_LOGIN_CODE = "/loginCode";//验证码登录
  public final static String URL_PROCESSING = "/login";//登录认证接口,security默认的接口
  public final static String URL_LOGOUT = "/exit";//注销退出接口
  public final static String guest_api = "/api/guest/";//token是选填

  public final static String guest_v10 = guest_api + v10;

  public final static String[] IGNORE_URLS = {"/","/error",guest_v10+"wechat/signIn",URL_LOGIN_PAGE,URL_INDEX_PAGE,URL_REGISTER,URL_GET_CODE,URL_USER_FORGET,URL_LOGIN_CODE,"/user/renewalToken","/user/logout","/webjars/**","/v2/api-docs","/swagge**","/**.ico","/**.html","/**.xlsx","/**.txt","/style/**.css","/swagger-resources","/swagger-resources/**"};

  public final static String ACCESS_TOKEN = "accessToken";

  public final static String REFRESH_TOKEN = "refreshToken";
  /*前端已登录的用户名*/
  public final static String currentLoginUser = "currentLoginUser";

  public final static String title = "<title>系统提示</title>";

  /**自定义code及msg*/
  public final static int code198 = 198;
  /**操作失败*/
  public final static int code199 = 199;
  /**操作失败*/
  public final static String msg199 = "操作失败";
  /**操作成功*/
  public final static int code200 = 200;
  /**操作成功*/
  public final static String msg200 = "操作成功";
  /**暂无数据*/
  public final static int code201 = 201;
  /**暂无数据*/
  public final static String msg201 = "暂无数据";
  /**请求参数有误*/
  public final static int code202 = 202;
  /**请求参数有误*/
  public final static String msg202 = "请求参数有误";
  /**token验证失败*/
  public final static int code203 = 203;
  /**token验证失败*/
  public final static String msg203 = "token验证失败";
  /**服务出现错误*/
  public final static int code204 = 204;
  /**服务出现错误*/
  public final static String msg204 = "服务出现错误";
  /**token无效或已过期,请重新登录*/
  public final static String token_invalid = "token无效或已过期,请重新登录";
  /**未登录或登录超时或token已失效*/
  public final static int code205 = 205;
  public final static String msg205 = "未登录或登录超时!";
  /**账号或密码不正确*/
  public final static int code206 = 206;
  /**账号或密码不正确*/
  public final static String msg206 = "账号或密码错误";
  /**非法操作!或你的账号已被删除|你的账号已被禁用,一般用于被迫强制退出登录*/
  public final static int code207 = 207;
  /**没有操作权限*/
  public final static int code401 = 401;
  /**没有操作权限*/
  public final static String msg401 = "没有操作权限";
  /**菜单的最顶级的pid值*/
  public final static String pid = "8888888888888888888";
  /**你的账号已被删除*/
  public final static String msg207 = "您的账号已被删除";
  /**分页的区间标识符*/
  public final static String section = "section";
  /**admin管理员的主键*/
  public final static String SUPER_KEY = "498276858362601488";
  /**admin管理员|administrator超级管理员的主键集合*/
  private final static Long[] SUPERS = {Long.parseLong(SUPER_KEY),498276858362601489L};
  /**定义全局变量图形验证码标识,便于登录验证图形验证码*/
  public final static String imageCode = "imageCode";
  /**统一全局的total总条数|总记录数json关键字key响应给客户端*/
  public final static String total = "total";
  /**统一全局的totalPage总页数json关键字key响应给客户端*/
  public final static String totalPage = "totalPage";
  /**统一全局的数据表格的数据返回json关键字key响应给客户端*/
  public final static String rows = "rows";
  /**统一全局的code的状态码json关键字key关键字响应给客户端*/
  public final static String code = "code";
  /**统一全局的msg提示消息json关键字key响应给客户端*/
  public final static String msg = "msg";
  /**统一全局的pageSize每页大小json关键字key响应给客户端或作为Mybatis的分页参数*/
  public final static String pageSize = "pageSize";
  /**统一全局的result返回数据(含分页的数据)json关键字key响应给客户端*/
  public final static String data = "data";
  /**每次返回的条数*/
  public final static String record = "record";
  /**datatable的总记录数*/
  public final static String recordsFiltered = "recordsFiltered";
  /**datatable的总记录数*/
  public final static String recordsTotal = "recordsTotal";
  //附加数据,适用于dataTable表格附加数据
  public final static String attach = "attach";
  /**统一全局的current当前页json关键字key响应给客户端*/
  public final static String current = "current";
  /**分页的默认大小*/
  public final static int size_default = 50;
  /**api分页的默认限制大小*/
  public final static int size_api_default = 50;

  /**验证是否是管理员,用法:final boolean manager = ConfigFile.manager(loginId);*/
  public static boolean manager(final Long loginKey){
    return Arrays.asList(SUPERS).contains(loginKey);
  }
}